﻿@model PluginModel

@Html.ValidationSummary(false)
@Html.HiddenFor(model => model.SystemName)

@if (ViewBag.RefreshPage == true)
{
    <script type="text/javascript">
        try {window.opener.document.forms['@(ViewBag.formId)'].@(ViewBag.btnId).click();}
        catch (e){}
        window.close();
    </script>
}

<div class="content">
    <div class="form-horizontal">
        <div class="panel-group">
            <div class="panel panel-default">
                <div class="panel-body">
                    @(Html.LocalizedEditor<PluginModel, PluginLocalizedModel>("plugin-localized",
                @<div>
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.ExtLabelFor(model => model.Locales[item].FriendlyName)
                        </div>
                        <div class="col-md-9">
                            @Html.ExtEditorFor(model => model.Locales[item].FriendlyName)
                            @Html.ValidationMessageFor(model => model.Locales[item].FriendlyName)
                        </div>
                    </div>
                    @Html.HiddenFor(model => model.Locales[item].LanguageId)
                </div>
    ,
                    @<div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.ExtLabelFor(model => model.FriendlyName)
                            </div>
                            <div class="col-md-9">
                                @Html.ExtEditorFor(model => model.FriendlyName)
                                @Html.ValidationMessageFor(model => model.FriendlyName)
                            </div>
                        </div>
                    </div>
    ))

                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.ExtLabelFor(model => model.DisplayOrder)
                        </div>
                        <div class="col-md-9">
                            @Html.ExtEditorFor(model => model.DisplayOrder)
                            @Html.ValidationMessageFor(model => model.DisplayOrder)
                        </div>
                    </div>
                    @if (Model.CanChangeEnabled)
                    {
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.ExtLabelFor(model => model.IsEnabled)
                            </div>
                            <div class="col-md-9">
                                @Html.ExtEditorFor(model => model.IsEnabled)
                                @Html.ValidationMessageFor(model => model.IsEnabled)
                            </div>
                        </div>
                    }
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.ExtLabelFor(model => model.SelectedSiteIds)
                        </div>
                        <div class="col-md-9">
                            <div class="row">
                                <div class="col-md-4">
                                    @Html.EditorFor(model => model.SelectedSiteIds, new {SelectList = Model.AvailableSites})
                                    <script>
                                        $(document).ready(function() {
                                            var sitesIdsInput = $('#@Html.FieldIdFor(model => model.SelectedSiteIds)').data("kendoMultiSelect");
                                            sitesIdsInput.setOptions({
                                                autoClose: false
                                            });

                                            @if (Model.AvailableSites.Count == 0)
                                            {
                                                <text>
                                    sitesIdsInput.setOptions({
                                        enable: false,
                                        placeholder: 'No sites available'
                                    });
                                    sitesIdsInput._placeholder();
                                    sitesIdsInput._enable();
                                    </text>
                                            }
                                        });
                                    </script>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>